﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="xbrlesita_osanik", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(XbrlesitaOsanik))]
    public class XbrlesitaOsanikSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IXbrlesitaOsanik clazz;
        
        public XbrlesitaOsanikSerializer(IXbrlesitaOsanik clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("liik");
            if (clazz.Liik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Liik))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Liik");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("kood");
            if (clazz.Kood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kood))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("koodiriik");
            if (clazz.Koodiriik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Koodiriik))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("synnikp");
            if (clazz.Synnikp!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Synnikp))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("eesnimi");
            if (clazz.Eesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesnimi))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("nimi");
            if (clazz.Nimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Nimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Nimi");
            }
            Writer.WriteEndElement();
            if (clazz.OsaSuurus!=null) {
                Writer.WriteStartElement("osa_suurus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "decimal");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDecimal(((decimal)(clazz.OsaSuurus))).ToString());
                Writer.WriteEndElement();
            }
            Writer.WriteStartElement("osa_valuuta");
            if (clazz.OsaValuuta!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OsaValuuta))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("aadress_riik");
            if (clazz.AadressRiik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressRiik))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("aadress_ehak");
            if (clazz.AadressEhak!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressEhak))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("aadress_tekst");
            if (clazz.AadressTekst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressTekst))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("aadress_postalcode");
            if (clazz.AadressPostalcode!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressPostalcode))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="liik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_osanik>liik");
                }
                clazz.Liik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("liik")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_osanik>liik", Reader.LocalName);
            }
            if (Reader.LocalName=="kood") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Kood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kood")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_osanik>kood", Reader.LocalName);
            }
            if (Reader.LocalName=="koodiriik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Koodiriik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("koodiriik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_osanik>koodiriik", Reader.LocalName);
            }
            if (Reader.LocalName=="synnikp") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Synnikp = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("synnikp")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_osanik>synnikp", Reader.LocalName);
            }
            if (Reader.LocalName=="eesnimi") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Eesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("eesnimi")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_osanik>eesnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="nimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesita_osanik>nimi");
                }
                clazz.Nimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("nimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_osanik>nimi", Reader.LocalName);
            }
            if (Reader.LocalName=="osa_suurus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.OsaSuurus = new global::Xtee.Core.Schema.XsdDecimal(Reader.ReadElementString("osa_suurus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="osa_valuuta") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.OsaValuuta = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("osa_valuuta")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_osanik>osa_valuuta", Reader.LocalName);
            }
            if (Reader.LocalName=="aadress_riik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AadressRiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_riik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_osanik>aadress_riik", Reader.LocalName);
            }
            if (Reader.LocalName=="aadress_ehak") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AadressEhak = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_ehak")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_osanik>aadress_ehak", Reader.LocalName);
            }
            if (Reader.LocalName=="aadress_tekst") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AadressTekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_tekst")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_osanik>aadress_tekst", Reader.LocalName);
            }
            if (Reader.LocalName=="aadress_postalcode") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AadressPostalcode = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_postalcode")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesita_osanik>aadress_postalcode", Reader.LocalName);
            }
        }
    }
}
